package dao;// 审核记录数据访问对象
import model.ReviewRecord;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class ReviewRecordDAO {
    public boolean createReviewRecord(ReviewRecord record) {
        String sql = "INSERT INTO review_records (application_id, reviewer_id, review_level, is_approved, review_comment) VALUES (?, ?, ?, ?, ?)";
        try (Connection conn = DBConnection.getConnection();
             PreparedStatement pstmt = conn.prepareStatement(sql)) {
            pstmt.setInt(1, record.getApplication().getId());
            pstmt.setInt(2, record.getReviewer().getId());
            pstmt.setInt(3, record.getReviewLevel());
            pstmt.setBoolean(4, record.isApproved());
            pstmt.setString(5, record.getReviewComment());
            int rows = pstmt.executeUpdate();
            return rows > 0;
        } catch (SQLException e) {
            e.printStackTrace();
            return false;
        }
    }
}    